//
//  ClassCollectionViewCell.m
//  MMLOOK
//
//  Created by dllo on 15/8/29.
//  Copyright (c) 2015年 武俊娥. All rights reserved.
//

#import "ClassCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@interface ClassCollectionViewCell ()

@property (nonatomic, retain)UIImageView *imageView;
@property (nonatomic, retain)UILabel *lable;

@end

@implementation ClassCollectionViewCell

- (void)dealloc
{
    [_lable release];
    [_imageView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self creatSubview];
    }
    return self;
}

- (void)creatSubview
{
    self.imageView = [[[UIImageView alloc] init] autorelease];
    [self.contentView addSubview:_imageView];
    
    self.lable = [[[UILabel alloc] init] autorelease];
    self.lable.textAlignment = NSTextAlignmentCenter;
    self.lable.font = [UIFont systemFontOfSize:15 * OffHeight];
    [self.contentView addSubview:_lable];
}

- (void)sendDic: (NSMutableDictionary *)dic
{
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:[dic objectForKey:@"icon_url"]]placeholderImage:[UIImage imageNamed:@"class.png"]];
    self.lable.text = [dic objectForKey:@"name"];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _imageView.frame = CGRectMake(5, 5, self.contentView.frame.size.width - 10,  self.contentView.frame.size.width - 10);
    _lable.frame = CGRectMake(0, _imageView.frame.origin.y + _imageView.frame.size.height, self.contentView.frame.size.width, self.contentView.frame.size.height - _imageView.frame.size.height - _imageView.frame.origin.y);
}

@end
